Websydian v6.1 online documentationOnline documentation - WebsydianExpress v3.5

Template Gen sections

Introduction

The generated sections are part of the new template generation functionality enabling you to generate a new version of a template file without destroying all manual changes you might have made to the generated templates.

The generated section markers are used to protect parts of the template that has been automatically generated from being changed when you create a new version of the template.

Gen section markers in the meta templates

As for the edit points, the generated section markers that will be inserted in the generated templates are HTML / JavaScript markers. To be able to insert the correct comment marker, two separate versions of the markers are used - one for inserting markers in HTML code - and one for inserting in JavaScript code.

A generated section is started by a start marker, that can have the following formats:

HTML:

/(%GENSECTIONHTMSTART-NameOfSection)

JavaScript:

/(%GENSECTIONJSSTART-NameOfSection)

The section is terminated by an end marker, that can have the following formats:

HTML:

/(%GENSECTIONHTMEND-NameOfSection)

JavaScript:

/(%GENSECTIONJSEND-NameOfSection)

Everything between the start marker and the corresponding end marker is the generated section.

Handling gen sections in template generation

When the template generation finds that it has to create a new file (when it starts handling a new MAIN template), it will save the content of all protected generated sections to a temporary (xml) file (A protected start comment line contains the text wsyd.generatedSection.begin.protected=Yes).

When the template generation encounters a GENSECTIONSTART marker in the meta template, it will start by checking whether the temporary file contains information about protected content for the generated section.

If not, it will insert a comment line:

HTML:

<!-- !wsyd.generatedSection.begin.protected=No - NameOfSection -->

JS:

// !wsyd.generatedSection.begin.protected=No - NameOfSection

If the temporary file contains protected information for the section, the template generation function will read until it finds the corresponding end section marker - but instead of performing replacement for this section, it will discard all the meta template content and insert the content from the temporary file instead.

In both cases, the template generation function will insert an end section marker as the final part of the section:

HTML:

<!-- !wsyd.generatedSection.end - NameOfSection -->

JS:

// !wsyd.generatedSection.end - NameOfSection

Using the generated sections

You protect a generated section by setting protected = Yes in the start marker of the GENSECTION marker in the generated template.

Limitations

Only one instance of a generated section in a template

Due to the way the content of the generated sections are handled, each generated template can only contain one generated section with a given name.

If a generated template contains more than one instance of an generated section, information for all the generated sections will be saved to the temporary file - but all the protected generated sections in the changed template will have the content of the first edit point.

This means that you should never insert a generated section in the grid region of a meta template or in one of the meta templates that is used as a grid child - or if the meta template is included in a grid child.

In general, it is recommended that you only introduce generated sections in the MAIN meta templates and their immediate child meta templates.

Removing generated section

If you change a meta template so that the markers for a generated section are removed, the generated section will no longer be protected - even though you set protected to Yes in the generated template.

Protecting a section that refers removed elements

By protecting a generated section, you override the normal template generation. This means that the objects referred in the protected section might no longer be available in the page due to changes in the Plex model.

In general, you should be careful when you remove or delete content from a PageGenerator if you have protected sections in the template used by the PageGenerator.